Types & Constants
Types​
APIResponseError
​
Occurs when there is an error processing the request.
interface APIResponseError {
error: true;
data?: any;
message: string;
code: AuthTokenCode | APIErrorCode;
}
AuthTokenMessage
​
The message returned from signAuthToken
.
type AuthTokenMessage {
description: string;
version: number;
validFrom: number;
validTo: number;
signer: Address;
nonce: number;
}
description
: the description of the token, e.g. "Chronicle API token"version
: the authentication API version numbervalidFrom
: unix epoch timestamp starting from then the token is valid, inclusivevalidTo
: unix epoch timestamp until when the auth token is valid, inclusivesigner
: the address of the signernonce
: unique number
Blockchain
​
A blockchain identifier of either the shortName
or chainId
per chainid.network.
type Blockchain = string | number;
PairData
​
The data structure returned from getPairs
type PairData = {
scheme: Scheme;
blockchain: Blockchain;
pairs: Pairs;
}
Pairs
​
The data structure containing pairs.
type Pairs = Record<string, { bar: number; validators: Address[] }>;
Example:
{
"BTC/USD": {
bar: 13,
validators: [
"0xabc123...",
"0xabc123...",
"0xabc123...",
...
]
}
}
PriceData
​
The data structure returned from getPrices
type PriceData = {
wat: string;
scheme: Scheme;
bar: number;
messages: PriceMessage[];
}
PriceMessage
​
The data structure of an individual price message. A batch of price messages makes up a single oracle price.
type PriceMessage {
wat: string;
val: string;
age: number;
r: string;
s: string;
v: string;
}
PriceRequest
​
The data structure of the argument passed to getPrices
type PriceRequest {
wat: string;
scheme?: Scheme;
}
ValidatorData
​
The data structure returned from getPairs
type ValidatorData {
scheme: Scheme;
validators: Validator[];
}
Constants​
Note: all enum values are identical to their keys, but only keys are shown here for simplicity
Scheme
​
Encryption scheme for price messages. Currently there is only one option, however more options may be offered in the future.
enum Scheme {
ECDSA
}
ECDSA
: Price messages are signed with Elliptic Curve Digital Signature Algorithm encryption.
AuthTokenCodes
​
Response codes for auth token verification.
enum AuthTokenCode {
VALID,
EXPIRED,
NOT_YET_VALID,
DURATION_EXCEEDS_MAX,
INVALID_SIGNATURE,
INVALID_VERSION,
MALFORMED_TOKEN,
SIGNER_NOT_AUTHORIZED
}
VALID
: Auth token is validEXPIRED
: Auth token end time has passedNOT_YET_VALID
: Auth token start time has not yet occurredDURATION_EXCEEDS_MAX
: The period between auth token start and end times is too longINVALID_SIGNATURE
: The auth tokensigner
field and recovered signature do not matchINVALID_VERSION
: The auth token is using an unrecognized versionMALFORMED_TOKEN
: The auth token has some other error not covered by the other codesSIGNER_NOT_AUTHORIZED
: The token signer is not authorized by Chronicle
APIErrorCode
​
Response codes for API errors.
enum APIErrorCode {
FAILED_REQUEST,
SCHEME_NOT_SUPPORTED,
BLOCKCHAIN_NOT_SUPPORTED,
PAIR_NOT_SUPPORTED,
MISSING_REQUIRED_PARAMETER,
METHOD_NOT_ALLOWED,
INVALID_REQUEST_DATA,
}
FAILED_REQUEST
: The API request failed to receive a valid response from the serverSCHEME_NOT_SUPPORTED
: The API request was made for a Scheme that is not supportedBLOCKCHAIN_NOT_SUPPORTED
: The API request was made for a Blockchain that is not supportedPAIR_NOT_SUPPORTED
: The API request was made for a Pair that is not supportedMISSING_REQUIRED_PARAMETER
: The API request was missing a required parameter and was therefore unable to completeMETHOD_NOT_ALLOWED
: The HTTP method used to access the API is not allowedINVALID_REQUEST_DATA
: The request data was not parseable or inadequate to complete the request